package csc.daonjpa.java.domain;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;

/**
 * Entity class for Account table. This is a simple POJO class with annotations
 * to define mapping with DB table
 * 
 * @author nvu3
 *
 */
@Entity(name = "account")
public class Account implements Serializable {
	
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "accountNumber")
	private String accountNumber;

	@Column(name = "accountName")
	private String accountName;

	@Column(name = "accountType")
	private String accountType;

	@Column(name = "availableNumber")
	private int availableNumber;
	
	@ManyToOne
	@JoinColumn(name = "loginId")
	private Customer customer;

	@OneToOne(mappedBy = "account")
	private Card card;

	public Card getCard() {
		return card;
	}

	public void setCard(Card card) {
		this.card = card;
	}

	public String getAccountNumber() {
		return accountNumber;
	}

	public void setAccountNumber(String accountNumber) {
		this.accountNumber = accountNumber;
	}

	public int getAvailableNumber() {
		return availableNumber;
	}

	public void setAvailableNumber(int availableNumber) {
		this.availableNumber = availableNumber;
	}


	/**
	 * Required constructor
	 */
	public Account() {

	}

	/**
	 * Other constructor, you can define as many constructors as you want, but
	 * the constructor without parameters is required
	 * 
	 * @param accountNumber
	 * @param accountName
	 * @param accountType
	 */

	/**
	 * @return AccountName
	 */
	public String getAccountName() {
		return this.accountName;
	}

	public Account(String accountNumber, String accountName,
			String accountType, int availableNumber, Customer customer) {
		super();
		this.accountNumber = accountNumber;
		this.accountName = accountName;
		this.accountType = accountType;
		this.availableNumber = availableNumber;
		
		this.customer = customer;
	}

	/**
	 * Set accountName
	 * 
	 * @param accountName
	 */
	public void setAccountName(String accountName) {
		this.accountName = accountName;
	}

	/**
	 * @return AccountType
	 */
	public String getAccountType() {
		return this.accountType;
	}

	/**
	 * Set accountType
	 * 
	 * @param accountType
	 */
	public void setAccountType(String accountType) {
		this.accountType = accountType;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

}